package com.qc.wintrax;

import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

import com.qc.wintrax.utils.SystemBarTintManager;

/**
 * Created by asus on 2016/8/2.
 */
public class BaseActivity extends FragmentActivity {

    protected Activity context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        WTApplication.getInstance().setOnActivityCreate(this);
//        setLanguage();
        DisplayMetrics screenMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(screenMetrics);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //状态栏透明 需要在创建SystemBarTintManager 之前调用。
            setTranslucentStatus(true);
        }
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        //使StatusBarTintView 和 actionbar的颜色保持一致，风格统一。
        tintManager.setStatusBarTintResource(R.color.lvse2);
        tintManager.setStatusBarTintColor(Color.parseColor("#73a617"));
        // 设置状态栏的文字颜色
        tintManager.setStatusBarDarkMode(true, this);
    }

//    public void setLanguage() {
//
//        LanguageSettingUtil.init(this);// 初始化
//        languageSetting = LanguageSettingUtil.get();// 检查是否已经初始化
//        String language = HBApplication.getInstance().getConfig("language");
//
//        if ("en".equals(language)) {
//            languageSetting.saveLanguage("en");// 设置为"ja"语言
//            LanguageSettingUtil.get().refreshLanguage();// 刷新
//        } else if ("zh".equals(language)) {
//            languageSetting.saveLanguage("zh");// 设置为"ja"语言
//            LanguageSettingUtil.get().refreshLanguage();// 刷新
//        }
//    }

    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
        Window win = getWindow();
        WindowManager.LayoutParams winParams = win.getAttributes();
        final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if (on) {
            winParams.flags |= bits;
        } else {
            winParams.flags &= ~bits;
        }
        win.setAttributes(winParams);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    /**
     * @author fujianxiong
     * @Description:(解析数据) create at  10:51
     **/
    public void parseJson(String json) {

    }

    /**
     * @author fujianxiong
     * @Description:(设置数据,更新UI) create at  10:51
     **/
    public void setData() {
    }


//    public DisplayImageOptions imageOptions() {
//        DisplayImageOptions options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.mipmap.moren_touxiang_xiao)
//                .showImageForEmptyUri(R.mipmap.moren_touxiang_xiao)
//                .showImageOnFail(R.mipmap.moren_touxiang_xiao)
//                .cacheInMemory(true)
//                .cacheOnDisk(true)
//                .build();
//        return options;
//    }
}
